#!/usr/bin/env python
# -*- coding: utf-8 -*-

from mm import *

class Mm_CSV(Mm):
	
	def __init__(self, file):
		global csv
		csv = None

		import csv
		
		conf = self.parse(file)
		
		self.set_status(conf[0])
		self.reader = None
		
	def read(self, *_file):
		if not _file:
			_file = self.get_status()
		else:
			_file = _file[0]
		
		try:
			of = open(_file, "rb")
			self.reader = csv.reader(of)
			result = []

			for i in self.reader:
				result.append(i)
			of.close()
			self.data = result[1:]
		except IOError:
			print "I can not open file", _file
			
		return result

# TESTY
#c = Mm_CSV("some.csv")
#c.read("some.csv")
#print c.get_data()
#print c.get_items()